package com.ddwl.gate.config;


import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.springframework.scheduling.annotation.SchedulingConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.scheduling.config.ScheduledTaskRegistrar;

import java.util.concurrent.ThreadFactory;

/**
 * @author FuZhaohui
 */
//@Configuration
public class ScheduleConfig implements SchedulingConfigurer {

    //@Bean
    public ThreadPoolTaskScheduler taskScheduler() {
        ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
                .setNameFormat("ddwl-pool-%d").build();
        ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
        scheduler.setPoolSize(10);
        scheduler.setThreadFactory(namedThreadFactory);
        return scheduler;
    }

   // @Override
    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
        taskRegistrar.setTaskScheduler(taskScheduler());
    }
}